Crate perseus_macro
source · [−]Expand description
Perseus
Perseus is a blazingly fast frontend web development framework built in Rust with support for generating page state at build-time, request-time, incrementally, or whatever you’d like! It supports reactivity using Sycamore, and builds on it to provide a fully-fledged framework for developing modern apps.
- 📕 Supports static generation (serving only static resources)
- 🗼 Supports server-side rendering (serving dynamic resources)
- 🔧 Supports revalidation after time and/or with custom logic (updating rendered pages)
- 🛠️ Supports incremental regeneration (build on demand)
- 🏭 Open build matrix (use any rendering strategy with anything else)
- 🖥️ CLI harness that lets you build apps with ease and confidence
- 🌐 Full i18n support out-of-the-box with Fluent
- 🏎 Lighthouse scores of 100 on desktop and over 95 on mobile
- ⚡ Support for hot state reloading (reload your entire app’s state after you make any code changes in development, Perseus is the only framework in the world that can do this, to our knowledge)
Usage
Here’s a taste of Perseus (see the tiny example for more):
use perseus::{Html, PerseusApp, Template};
use sycamore::view;
#[perseus::main]
pub fn main<G: Html>() -> PerseusApp<G> {
PerseusApp::new().template(|| {
Template::new("index").template(|_| {
view! {
p { "Hello World!" }
}
})
})
}
Check out the book to learn how to turn that into your next app!
Aim
Support every major rendering strategy and provide developers the ability to efficiently create super-fast apps with Rust and a fantastic developer experience!
Motivation
There is a sore lack of Rust frameworks for frontend development that support more than just SPAs and client-side rendering, and so Perseus was born. We need something like NextJS for Wasm (but why stop there?).
Contributing
We appreciate all kinds of contributions, check out our contributing guidelines for more information! Also, please be sure to follow our code of conduct.
You can also chat about Perseus on our channel on Sycamore’s Discord server.
License
See LICENSE
.
Features
live-reload
– enables reloading the browser automatically when you make changes to your apphsr
– enables hot state reloading, which reloads the state of your app right before you made code changes in development, allowing you to pick up where you left off
Packages
This is the API documentation for the perseus-macro
package, which manages Perseus’ procedural macros. Note that Perseus mostly uses the book for
documentation, and this should mostly be used as a secondary reference source. You can also find full usage examples here.
Attribute Macros
String
s under the
hood for both simplicity and to avoid bundle size increases from excessive monomorphization. This macro aims to prevent the need for
manually serializing and deserializing everything! This takes the type of function that it’s working on, which must be one of the
following:<head>
.lib.rs
file of your project.struct
to create a reactive version by wrapping each field in a Signal
. This will generate a new struct
with the given name and implement a .make_rx()
method on the original that allows turning an instance of the unreactive struct
into an instance of the reactive one..template()
function, avoiding the need for you to manually serialize/deserialize things. This should be provided the name of the Sycamore component (same as given
to Sycamore’s #[component()]
, but without the <G>
).#[template]
designed for reactive state. This can interface automatically with global state, and will automatically provide Sycamore #[component]
annotations. To
use this, you don’t need to provide anything other than an optional custom type parameter letter (by default, G
will be used). Unlike with the original macro, this will automatically
handle component names internally.async fn foo(client: &mut fantoccini::Client) -> Result<>
.